package com.zhixi.dao.impl;

import com.zhixi.dao.UserDao;
import com.zhixi.mapper.UserMapper;
import com.zhixi.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @ClassName UserDaoImpl
 * @Author zhangzhixi
 * @Description
 * @Date 2022-12-26 21:31
 * @Version 1.0
 */
@Service
public class UserDaoImpl implements UserDao {

    @Resource
    private UserMapper userMapper;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public User login(User user) {
        User userDb = userMapper.login(user);
        if (userDb != null) {
            return userDb;
        }
        throw new RuntimeException("认证失败");
    }
}
